package com.yanqu.road.server.cmd.grandchild.genealogy;

import com.yanqu.road.pb.grandchild.GrandChildProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.grandson.GrandChildModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = GameProtocol.S_GRAND_CHILD_PROFESSION_SKILL_UPGRADE,desc = "升级孙子职业技能")
public class UpgradeProfessionSkillCmd extends AbstractCommand {
    private int professionId;       //职业技能编号
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        GrandChildProto.UpgradeFamilyTreeSkillReqMsg reqMsg = GrandChildProto.UpgradeFamilyTreeSkillReqMsg.parseFrom(packet.getBytes());
        professionId = reqMsg.getProfessionId();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ret = player.getModule(GrandChildModule.class).grandChildProfessionSkillUpgrade(professionId);
    }

    @Override
    public void sendData(GamePlayer player) {
        GrandChildProto.UpgradeFamilyTreeSkillRespMsg.Builder respMsg = GrandChildProto.UpgradeFamilyTreeSkillRespMsg.newBuilder();
        respMsg.setRet(ret);
        player.sendPacket(Protocol.U_GRAND_CHILD_PROFESSION_SKILL_UPGRADE, respMsg);
    }
}
